# -*- coding: utf-8 -*- 
import time
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

brower = webdriver.Chrome(executable_path = r"D:/user/Downloads/chromedriver")
brower.get("http://itsm-rpt.sf-express.com/balantflow/")

#账号
zh = brower.find_element_by_id("username")
zh.send_keys("01383317")

#密码RL003692515
mm = brower.find_element_by_id("password")
mm.send_keys("liuj1a!wei")
print u"""
          请输入验证码
          有8秒时间
		  请不要点击登录按钮
		  """
time.sleep(8)
print u"自动点击登陆"
brower.find_element_by_css_selector(".f18.logn_lt.logn_btn.lh46").click()
print u"打开新标签OK"
js = " window.open('http://itsm-rpt.sf-express.com/balantflow/task/getTaskDetail.do?taskId=3691529')"
print u"打开新网页OK"
brower.execute_script(js)
print u"切换到新标签OK"
tabs = brower.window_handles
brower.switch_to_window(tabs[1])

a = brower.find_elements_by_class_name("divTitle")
b = brower.find_elements_by_class_name("divControl")

asj = b[28].text#A时间是正式发布时间,B时间是维护窗口
asj1 = asj.split()#[u'\u5f00\u59cb\u65f6\u95f4\uff1a', u'2019-01-09', u'12:00', u'-', u'\u7ed3\u675f\u65f6\u95f4\uff1a', u'2019-01-09', u'15:00']
bsj = b[6].text
bsj1 = bsj.split("-")#[u'12:00', u'15:00']

print u"=========以下为检查结果============"
if asj1[1] == asj1[5] and asj1[2] <= bsj1[0] and asj1[6] <= bsj1[1]:
    print u"系统在维护窗口"
else:
    print u"系统不再维护窗口,再看一次咯"
print  a[0].text, b[0].text
#for i in range(len(a)):
#    print a[i].text
#for i1 in range(len(b)):
#    print b[i1].text
